﻿/*
Copyright (c) 2008 Martin Legris

Permission is hereby granted, free of charge, to any person obtaining a copy of this 
software and associated documentation files (the "Software"), to deal in the Software 
without restriction, including without limitation the rights to use, copy, modify, 
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
permit persons to whom the Software is furnished to do so, subject to the following 
conditions:

The above copyright notice and this permission notice shall be included in all copies 
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ignore
*/
package newcommerce.lastfm.api.clients 
{
	import flash.events.ErrorEvent;
	import newcommerce.lastfm.api.data.LFMImageData;
	import newcommerce.lastfm.api.events.LFMArtistEvent;
	import newcommerce.lastfm.api.events.LFMArtistImageEvent;
	import newcommerce.lastfm.api.feeds.LFMArtistFeed;
	import newcommerce.lastfm.api.feeds.LFMArtistImageFeed;
	import newcommerce.lastfm.api.feeds.LFMImageFeed;
	import newcommerce.lastws.AbstractClient;
	import com.gsolo.encryption.MD5;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;
	import flash.net.URLVariables;
	import newcommerce.lastfm.api.data.LFMArtistInfo;
	import newcommerce.lastfm.api.events.LFMArtistInfoEvent;
	import newcommerce.lastfm.api.events.LFMArtistTagEvent;
	import newcommerce.lastfm.api.events.LFMEventFeedEvent;
	import newcommerce.lastfm.api.events.LFMFanFeedEvent;
	import newcommerce.lastfm.api.events.LFMShareEvent;
	import newcommerce.lastfm.api.events.LFMSimilarArtistEvent;
	import newcommerce.lastfm.api.events.LFMTagFeedEvent;
	import newcommerce.lastfm.api.events.LFMTopAlbumsEvent;
	import newcommerce.lastfm.api.events.LFMTopTrackEvent;
	import newcommerce.lastfm.api.feeds.LFMAlbumFeed;
	import newcommerce.lastfm.api.feeds.LFMEventFeed;
	import newcommerce.lastfm.api.feeds.LFMFanFeed;
	import newcommerce.lastfm.api.feeds.LFMSimilarArtistFeed;
	import newcommerce.lastfm.api.feeds.LFMTagFeed;
	import newcommerce.lastfm.api.feeds.LFMTrackFeed;
	import newcommerce.lastfm.api.LastFMClient;
	import newcommerce.lastws.RequestWrapper;
	
	/**
	 * ...
	 * @author Martin Legris ( http://blog.martinlegris.com )
	 */
	
	 	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMArtistInfoEvent.DATA_READY
	 */
	[Event(name="lfm_artist_info_data_ready",type="newcommerce.lastfm.api.events.LFMArtistInfoEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMSimilarArtistEvent.FEED_READY
	 */
	[Event(name="lfm_similar_artist_feed_ready",type="newcommerce.lastfm.api.events.LFMSimilarArtistEvent")] 
	
	
	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMSimilarArtistEvent.REQUEST_FAILED
	 */
	[Event(name="lfm_similar_artist_request_failed",type="newcommerce.lastfm.api.events.LFMSimilarArtistEvent")] 
	
	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMTagFeedEvent.FEED_READY
	 */
	[Event(name="lfm_tag_feed_ready",type="newcommerce.lastfm.api.events.LFMTagFeedEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMFanFeedEvent.FEED_READY
	 */
	[Event(name="lfm_fan_feed_ready",type="newcommerce.lastfm.api.events.LFMFanFeedEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMTopTrackEvent.FEED_READY
	 */
	[Event(name="lfm_top_tracks_feed_ready",type="newcommerce.lastfm.api.events.LFMTopTrackEvent")] 
	
	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMTopAlbumsEvent.FEED_READY
	 */
	[Event(name="lfm_top_albums_feed_ready",type="newcommerce.lastfm.api.events.LFMTopAlbumsEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMArtistTagEvent.TAGS_ADDED
	 */
	[Event(name="lfm_artist_tags_added",type="newcommerce.lastfm.api.events.LFMArtistTagEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMArtistTagEvent.TAGS_NOT_ADDED
	 */
	[Event(name="lfm_artist_tags_not_added",type="newcommerce.lastfm.api.events.LFMArtistTagEvent.TAGS_NOT_ADDED")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMArtistTagEvent.TAG_REMOVED
	 */
	[Event(name="lfm_artist_tag_removed",type="newcommerce.lastfm.api.events.LFMArtistTagEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMArtistTagEvent.TAG_NOT_REMOVED
	 */
	[Event(name="lfm_artist_tag_not_removed",type="newcommerce.lastfm.api.events.LFMArtistTagEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMShareEvent.SUCCESS
	 */
	[Event(name="lfm_share_success",type="newcommerce.lastfm.api.events.LFMShareEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMShareEvent.FAILURE
	 */
	[Event(name="lfm_share_failure",type="newcommerce.lastfm.api.events.LFMShareEvent")] 
	
	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMEventFeedEvent.FEED_READY
	 */
	[Event(name="lfm_event_feed_ready",type="newcommerce.lastfm.api.events.LFMEventFeedEvent")] 

	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMEventFeedEvent.REQUEST_FAILED
	 */
	[Event(name="lfm_event_feed_request_failed",type="newcommerce.lastfm.api.events.LFMEventFeedEvent")] 


	/**
	 * Dispatched when the user artist info is ready.
	 * @eventType newcommerce.lastfm.api.events.LFMArtistEvent.FEED_READY
	 */
	[Event(name="lfm_artist_event_feed_ready",type="newcommerce.lastfm.api.events.LFMArtistEvent")]

	
	public class ArtistClient extends AbstractClient
	{
		public function ArtistClient() 
		{
			super();
		}
		
		// REQUESTS
		
		public function getSimilar(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.getSimilar&artist=" + encodeURIComponent(artistName) + "&api_key=" + LastFMClient.apiKey;
			
			return runLoader(new URLRequest(url), doSimilar, doSimilarError, createWrapper({ artist:artistName }));
		}
		
		public function getImages(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.getImages&artist=" + encodeURIComponent(artistName) + "&api_key=" + LastFMClient.apiKey;
			
			return runLoader(new URLRequest(url), doImages, doImagesError, createWrapper( { artist:artistName } ));
		}
		
		public function getInfo(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.getInfo&artist=" + encodeURIComponent(artistName) + "&autocorrect=1&api_key=" + LastFMClient.apiKey;
			return runLoader(new URLRequest(url), doInfo, doInfoError, createWrapper({ artist:artistName }));
		}
		
		public function getEvents(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl;
			
			var variables:URLVariables = new URLVariables();
			variables.artist = artistName;
			variables.api_key = LastFMClient.apiKey;
			variables.method = "artist.getEvents";
			
			var request:URLRequest = new URLRequest(url);
			request.data = variables;
			
			return runLoader(request, doEvents, doEventsError, createWrapper({ artist: artistName }) );
		}
		
		public function getTopTags(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.getTopTags&artist=" + encodeURIComponent(artistName) + "&api_key=" + LastFMClient.apiKey;
			return runLoader(new URLRequest(url), doTopTags, doTopTagsError, createWrapper( { artist:artistName } ) );
		}
		
		public function getTopFans(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.getTopFans&artist=" + encodeURIComponent(artistName) + "&api_key=" + LastFMClient.apiKey;
			return runLoader(new URLRequest(url), doTopFans, doTopFansError, createWrapper( { artist:artistName } ) );
		}
		
		public function getTopTracks(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.getTopTracks&artist=" + encodeURIComponent(artistName) + "&api_key=" + LastFMClient.apiKey;
			return runLoader(new URLRequest(url), doTopTracks, doTopTracksError, createWrapper( { artist: artistName } ));
		}
		
		public function search(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl + "?method=artist.search&artist=" + encodeURIComponent(artistName) + "&api_key=" + LastFMClient.apiKey;
			return runLoader(new URLRequest(url), doSearch, doSearchError, createWrapper ({ artist:artistName } ) );
		}
		
		public function getTopAlbums(artistName:String):Number
		{
			var url:String = LastFMClient.baseUrl;
			var variables:URLVariables = new URLVariables;
			variables.method = "artist.getTopAlbums";
			variables.artist = artistName;
			variables.api_key = LastFMClient.apiKey;
			
			var request:URLRequest = new URLRequest(url);
			request.data = variables;
			
			return runLoader(request, doTopAlbums, doTopAlbumsError, createWrapper({ artist:artistName }) );
		}
		
		public function share(artistName:String, recipients:Array, message:String = ""):Number
		{
			var url:String = LastFMClient.baseUrl;
			var sig:String = "api_key" + LastFMClient.apiKey + "artist" + artistName;
			if (message != "")
				sig += "message" + message;
			sig += "methodartist.sharerecipient" + recipients.join(",") + "sk" + LastFMClient.sessionKey + LastFMClient.secret;			
			var request:URLRequest = new URLRequest(url);
			
			var variables:URLVariables = new URLVariables();
			variables.artist = artistName;
			variables.recipient = recipients.join(",");
			if (message != "")
				variables.message = message;
			variables.sk = LastFMClient.sessionKey;
			variables.api_sig = MD5.encrypt(sig);
			variables.method = "artist.share";
			variables.api_key = LastFMClient.apiKey;
			
			request.data = variables;
			request.method = URLRequestMethod.POST;
			
			return runLoader(request, doShared, doShareError, createWrapper( { artist:artistName, recipient:recipients.join(","), message:message } ));
		}
		
		public function addTags(artistName:String, tags:Array):Number
		{
			var url:String = LastFMClient.baseUrl;			
			var sig:String = "api_key" + LastFMClient.apiKey + "artist" + artistName + "methodartist.addTagssk" + LastFMClient.sessionKey + "tags" + tags.join(",") + LastFMClient.secret;
			var request:URLRequest = new URLRequest(url);
			
			var variables:URLVariables = new URLVariables();
			variables.tags = tags.join(",");
			variables.artist = artistName;
			variables.api_key = LastFMClient.apiKey;
			variables.sk = LastFMClient.sessionKey;
			variables.api_sig = MD5.encrypt(sig);
			variables.method = "artist.addTags";
			
			request.data = variables;
			request.method = URLRequestMethod.POST;
			
			return runLoader(request, doTagsAdded, doTagsAddError, createWrapper({ func:"artist.addTags", artist:artistName, tags:tags.join(",") } ) );
		}
		
		public function removeTag(artistName:String, tag:String):Number
		{
			var url:String = LastFMClient.baseUrl;
			var sig:String = "api_key" + LastFMClient.apiKey + "artist" + artistName + "methodartist.removeTagsk" + LastFMClient.sessionKey + "tag" + tag + LastFMClient.secret;
			var request:URLRequest = new URLRequest(url);
			
			var variables:URLVariables = new URLVariables();
			variables.tag = tag;
			variables.artist = artistName;
			variables.api_key = LastFMClient.apiKey;
			variables.sk = LastFMClient.sessionKey;
			variables.api_sig = MD5.encrypt(sig);
			variables.method = "artist.removeTag";
			
			request.data = variables;
			request.method = URLRequestMethod.POST;
			
			return runLoader(request, doTagRemoved, doTagRemoveError, createWrapper( { func:"artist.removeTag", artist:artistName, tag:tag } ));
		}
		
		
		// RESPONSE HANDLING
		
		protected function doInfo(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);

			if (xml.@status == "ok")
			{
				var artistInfo:LFMArtistInfo = LFMArtistInfo.fromXML(xml.artist[0]);
				dispatchEvent(new LFMArtistInfoEvent(LFMArtistInfoEvent.DATA_READY, artistInfo, wrapper.requestId));
			}
			else
			{
				dispatchEvent(new LFMArtistInfoEvent(LFMArtistInfoEvent.REQUEST_FAILED, null, wrapper.requestId));
			}
		}
		
		protected function doInfoError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMArtistInfoEvent(LFMArtistInfoEvent.REQUEST_FAILED, null, wrapper.requestId));
		}
		
		// IMAGES
		
		protected function doImages(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var feed:LFMArtistImageFeed = new LFMArtistImageFeed(xml.images[0]);
				dispatchEvent(new LFMArtistImageEvent(LFMArtistImageEvent.FEED_READY, feed, wrapper.requestId, wrapper));
			}
			else
			{
				dispatchEvent(new LFMArtistImageEvent(LFMArtistImageEvent.REQUEST_FAILED, null, wrapper.requestId, wrapper));
			}
		}
		
		protected function doImagesError(evt:Event, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMArtistImageEvent(LFMArtistImageEvent.REQUEST_FAILED, null, wrapper.requestId, wrapper));
		}
		
		
		// SIMILAR ARTIST
		
		protected function doSimilar(evt:Event):void
		{		
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var feed:LFMSimilarArtistFeed = new LFMSimilarArtistFeed(xml.children()[0], xml.similarartists.@artist.toString());
				dispatchEvent(new LFMSimilarArtistEvent(LFMSimilarArtistEvent.FEED_READY, feed, wrapper.requestId));
			}
			else
			{
				trace("doSimilar xml.@status != ok");
				trace(xml.@status);
				dispatchEvent(new LFMSimilarArtistEvent(LFMSimilarArtistEvent.REQUEST_FAILED, null, wrapper.requestId));
			}
		}
		
		protected function doSimilarError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			trace("ArtistClient.doSimilarError:" + evt.text);
			dispatchEvent(new LFMSimilarArtistEvent(LFMSimilarArtistEvent.REQUEST_FAILED, null, wrapper.requestId));
		}
		
		
		// TOP TAGS
		
		protected function doTopTags(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var tagFeed:LFMTagFeed = new LFMTagFeed(xml.children()[0]);
				dispatchEvent(new LFMTagFeedEvent(LFMTagFeedEvent.FEED_READY, tagFeed, "artist", wrapper.artist, wrapper.requestId));
			}
		}
		
		protected function doTopTagsError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMTagFeedEvent(LFMTagFeedEvent.REQUEST_FAILED, null, "artist", wrapper.artist, wrapper.requestId));
		}
		
		
		// TOP FANS
		
		protected function doTopFans(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var fanFeed:LFMFanFeed = new LFMFanFeed(xml.topfans[0]);
				dispatchEvent(new LFMFanFeedEvent(LFMFanFeedEvent.FEED_READY, fanFeed, wrapper.requestId));
			}
		}
		
		protected function doTopFansError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMFanFeedEvent(LFMFanFeedEvent.REQUEST_FAILED, null, wrapper.requestId));
		}
		
		
		// TOP TRACKS
		
		protected function doTopTracks(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var feed:LFMTrackFeed = new LFMTrackFeed(xml.toptracks[0]);
				dispatchEvent(new LFMTopTrackEvent(LFMTopTrackEvent.FEED_READY, feed, wrapper.requestId));
			}
		}
		
		protected function doTopTracksError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMTopTrackEvent(LFMTopTrackEvent.REQUEST_FAILED, null, wrapper.requestId));
		}
		
		
		// TOP ALBUMS
		
		protected function doTopAlbums(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var feed:LFMAlbumFeed = new LFMAlbumFeed(xml.children()[0]);
				dispatchEvent(new LFMTopAlbumsEvent(LFMTopAlbumsEvent.FEED_READY, feed, wrapper.requestId));
			}
			else
			{
				trace("topAlbums not received");
			}	
		}
		
		protected function doTopAlbumsError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMTopAlbumsEvent(LFMTopAlbumsEvent.REQUEST_FAILED, null, wrapper.requestId));
		}
		
		
		// TAGS ADDED
		
		protected function doTagsAdded(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
				dispatchEvent(new LFMArtistTagEvent(LFMArtistTagEvent.TAGS_ADDED, wrapper.requestId));
			else
				dispatchEvent(new LFMArtistTagEvent(LFMArtistTagEvent.TAGS_NOT_ADDED, wrapper.requestId));
		}
		
		protected function doTagsAddError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMArtistTagEvent(LFMArtistTagEvent.TAGS_NOT_ADDED, wrapper.requestId));
		}
		
		
		// TAGS REMOVED
		
		protected function doTagRemoved(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")			
				dispatchEvent(new LFMArtistTagEvent(LFMArtistTagEvent.TAG_REMOVED, wrapper.requestId));
			else
				dispatchEvent(new LFMArtistTagEvent(LFMArtistTagEvent.TAG_NOT_REMOVED, wrapper.requestId));
		}
		
		protected function doTagRemoveError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMArtistTagEvent(LFMArtistTagEvent.TAG_NOT_REMOVED, wrapper.requestId));
		}
		
		
		// SHARING WITH FRIENDS
		
		protected function doShared(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				dispatchEvent(new LFMShareEvent(LFMShareEvent.SUCCESS, wrapper.requestId));
			}
			else
			{
				dispatchEvent(new LFMShareEvent(LFMShareEvent.FAILURE, wrapper.requestId));
			}
			
			trace(xml);
		}
		
		protected function doShareError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMShareEvent(LFMShareEvent.FAILURE, wrapper.requestId));
		}
		
		
		// EVENTS
		
		protected function doEvents(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var feed:LFMEventFeed = new LFMEventFeed(xml.events[0]);
				dispatchEvent(new LFMEventFeedEvent(LFMEventFeedEvent.FEED_READY, feed, wrapper.requestId));
			}
			else
			{
				dispatchEvent(new LFMEventFeedEvent(LFMEventFeedEvent.REQUEST_FAILED, null, wrapper.requestId));
			}
		}
		
		protected function doEventsError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMEventFeedEvent(LFMEventFeedEvent.REQUEST_FAILED, null, wrapper.requestId));
		}
		
		
		// ARTIST SEARCH
		
		protected function doSearch(evt:Event):void
		{
			var data:String = evt.target.data as String;
			var xml:XML = new XML(data);
			var wrapper:RequestWrapper = getWrapper(evt.target as URLLoader);
			
			if (xml.@status == "ok")
			{
				var feed:LFMArtistFeed = new LFMArtistFeed(xml.results.artistmatches[0]);
				dispatchEvent(new LFMArtistEvent(LFMArtistEvent.FEED_READY, feed, wrapper.requestId, wrapper));
			}
		}
		
		protected function doSearchError(evt:ErrorEvent, wrapper:RequestWrapper):void
		{
			dispatchEvent(new LFMArtistEvent(LFMArtistEvent.REQUEST_FAILED, null, wrapper.requestId, wrapper));
		}
	}
}